﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZFine.Application.Project;
using ZFine.Application.SystemManage;
using ZFine.Code;
using ZFine.Domain.Entity;
using ZFine.Web;

namespace Logiv.WEB.Areas.Project.Controllers
{
    public class MemberController : BaseController
    {
        MemberApp memberapp=new MemberApp();
        //private UserApp userApp = new UserApp();
        // GET: Project/Member
        public ActionResult Index()
        {
            return View();
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            //MemberEntity member = new MemberEntity();
            ////member.F_Id = "5bae0675-1004-439b-ae50-6a2bcdc5382211";
            //member.MerchantP = new UserEntity() { F_Id = "d6973303-c3d4-4dc2-99cd-dc5a745083c2" };
            //memberapp.SubmitForm(member, "");
            
            var reuslt = memberapp.GetList(pagination, keyword);
            var result = (from num in reuslt
                select new MemberEntity{
                    F_Id = num.F_Id,
                    MerchantP = num.MerchantP == null
                        ? null
                        : new UserEntity()
                        {
                            F_Id = num.MerchantP.F_Id
                        }
                }).ToList();
            var data = new
            {
                rows = result,
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }
    }
}